package com.jiaming.restaurant.api.restaurant.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiaming.restaurant.api.common.bean.vo.MyPageVO;
import com.jiaming.restaurant.api.goods.bean.entity.Goods;
import com.jiaming.restaurant.api.restaurant.bean.entity.Restaurant;
import com.jiaming.restaurant.api.restaurant.bean.vo.PageVO;
import com.jiaming.restaurant.api.restaurant.mapper.RestaurantMapper;
import com.jiaming.restaurant.api.restaurant.service.IRestaurantService;
import org.springframework.stereotype.Service;

/**
 * @author dragon
 * @create 2020-12-28 14:58
 */
@Service
public class RestaurantServiceImpl extends ServiceImpl<RestaurantMapper, Restaurant>
        implements IRestaurantService {
    @Override
    public MyPageVO<Restaurant> page(PageVO pageVO) {
        Page<Restaurant> page = new Page<>(pageVO.getPageNum(), pageVO.getPageSize());
        Page<Restaurant> restPage = this.page(page);
        MyPageVO<Restaurant> restMyPageVO = new MyPageVO<>();
        restMyPageVO.setItems(restPage.getRecords());
        restMyPageVO.setPageNum(restPage.getCurrent());
        restMyPageVO.setPageSize(restPage.getSize());
        restMyPageVO.setTotalItems(restPage.getTotal());
        restMyPageVO.setTotalPages(restPage.getPages());
        return restMyPageVO;
    }
}
